import 'package:base_lib/common/base/base_bloc_page.dart';
import 'package:base_lib/common/widget/bottom_bar/index.dart';
import 'package:base_lib/router/parameters.dart';
import 'package:base_lib/theme/theme_global.dart';
import 'package:doctor_app/home_page/page.dart';
import 'package:doctor_app/main_page/bloc.dart';
import 'package:doctor_app/mine_page/page.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class MainPage extends BaseBlocPage<MainBloc, _MainPageState> {
  MainPage(Parameters parameters) : super(parameters);

  @override
  _MainPageState generateThemeState() {
    return _MainPageState();
  }
}

class _MainPageState extends BaseBlocPageState<MainBloc> {
  int pageIndex = 0;

  List<BottomBarItem> bottomItems = [
    BottomBarItem(
        icon: Image.asset("images/tabbar_home_normal.png"),
        selectedIcon: Image.asset("images/tabbar_home_selected.png"),
        unSelectedTitle: "首页"),

    BottomBarItem(
        icon: Image.asset("images/tabbar_mine_normal.png"),
        selectedIcon: Image.asset("images/tabbar_mine_selected.png"),
        unSelectedTitle: "我的")
  ];

  final pages = <Widget>[HomePage(null), MinePage(null)];

  @override
  Widget buildChild(BuildContext context, MTheme theme) {
    return Scaffold(
        body: Column(
          children: [
            Expanded(
              child: IndexedStack(
                index: pageIndex,
                children: pages,
              ),
            ),
            BottomBar(
              currentIndex: pageIndex,
              items: bottomItems,
              onTap: (index) {
                setState(() {
                  pageIndex = index;
                });
              },
            )
          ],
        ),
      );
  }

  @override
  MainBloc generateBloc() {
    return MainBloc();
  }
}
